<?php
	/**
	* Video Categories Save
	* @author: trungdt
	* @since: Oct 26, 2011
	* @version: 1.0
	* 
	* Change logs
	* feb 1, 2011 - trungdt - first create
	* 
	*/

	if (!defined('EXPONENT')) exit('');
	if (exponent_users_isAdmin() || exponent_permissions_check(array("administrate", "edit", "create", "edit"), $loc))
	{
		$video_cat = null;
		if (!empty($_POST['id'])) {
			$video_cat = $db->selectObject('videomodule_cat', 'id='.intval($_POST['id']));
		}

		$video_cat->title=_ab_safe_html_string($_POST['title']);
		$video_cat->seo_name=_ab_safe_html_string($_POST['seo_name']);
		if ($video_cat->seo_name == "")
			$video_cat->seo_name = _to_vietnamese_with_nomark($video_cat->title);
		$video_cat->seo_name=_ab_check_seoname("videomodule_cat",$video_cat->seo_name, $video_cat->id);
		$video_cat->search_des=_ab_safe_html_string($_POST['search_des']);
		$video_cat->location_data=serialize($loc);

		if (isset($video_cat->id)) {
			$db->updateObject($video_cat,'videomodule_cat');
		} else {
			$db->insertObject($video_cat,'videomodule_cat');
		}

		exponent_flow_redirect();
	}
?>